<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--解决ie9以下浏览器对html5新增标签的不识别，并导致CSS不起作用的问题-->
    <!--解决ie9以下浏览器对 css3 Media Query 的不识别 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
    <title>Document</title>
</head>

<body>
    <main>
        <p class="refreshText"></p>
        <ul id="refreshContainer">
            <li>111</li>
            <li>222</li>
            <li>333</li>
            <li>444</li>
            <li>555</li>
            ...
        </ul>
    </main>



    <script>
        (function(window) {
            var _element = document.getElementById('refreshContainer'),
                _refreshText = document.querySelector('.refreshText'),
                _startPos = 0,
                _transitionHeight = 0;

            _element.addEventListener('touchstart', function(e) {
                console.log('初始位置：', e.touches[0].pageY);
                _startPos = e.touches[0].pageY;
                _element.style.position = 'relative';
                _element.style.transition = 'transform 0s';
            }, false);

            _element.addEventListener('touchmove', function(e) {
                console.log('当前位置：', e.touches[0].pageY);
                _transitionHeight = e.touches[0].pageY - _startPos;

                if (_transitionHeight > 0 && _transitionHeight < 60) {
                    _refreshText.innerText = '下拉刷新';
                    _element.style.transform = 'translateY(' + _transitionHeight + 'px)';

                    if (_transitionHeight > 55) {
                        _refreshText.innerText = '释放更新';
                    }
                }
            }, false);

            _element.addEventListener('touchend', function(e) {
                _element.style.transition = 'transform 0.5s ease 1s';
                _element.style.transform = 'translateY(0px)';
                _refreshText.innerText = '更新中...';

                // todo...

            }, false);
        })(window);
    </script>
</body>

</html>